#ifndef QCOLORGROUPDIALOG_H
#define QCOLORGROUPDIALOG_H

#include "../qbasedialog.h"
#include <QList>
namespace Ui {
class QColorGroupDialog;
}

#include <QLabel>
#include <QVariant>

class QwtThermo;

struct tagColorPosition
{
    QColor  m_color;
    int     m_position;
};

class QColorPositionBar: public QWidget
{
    Q_OBJECT
public:
    QColorPositionBar(QWidget* parent=0);
    ~QColorPositionBar();

    QList<tagColorPosition*> get_positions();
    tagColorPosition*        get_position(int index);

    void    set_current(int index);

    void    add_position(int pos,const QColor& color);
    void    remove_position(int pos);
    void    set_position(int index,int pos);
    int     get_current();
protected:
    void    mouseReleaseEvent(QMouseEvent *);
    void    mousePressEvent(QMouseEvent *);
    void    mouseMoveEvent(QMouseEvent *);
    void    paintEvent(QPaintEvent *);
signals:
    void    current_changed();
    void    refresh();
protected:
    QList<tagColorPosition*>    m_positions;
    int             m_current_index;
    int             m_press_pos;
    bool            m_is_clicked;
    QPoint          m_press_position;
};


class QColorGroupDialog : public QBaseDialog
{
    Q_OBJECT
    
public:
    explicit QColorGroupDialog(const QVariant &value,QWidget *parent = 0);
    ~QColorGroupDialog();
    
    QVariant    get_value();

protected:
    bool    eventFilter(QObject *, QEvent *);
private slots:
    void on_comboBox_currentIndexChanged(int index);
    void pos_refresh();
    void on_spinBox_valueChanged(int arg1);
    void current_changed();
    void on_pushButton_4_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_clicked();

private:
    Ui::QColorGroupDialog *ui;

    QVariant    m_value;
    QGradient   m_colors;
    QwtThermo   *m_thermo;
    QColorPositionBar   *m_bar;
};

#endif // QCOLORGROUPDIALOG_H
